# Generated by Django 4.2.5 on 2023-11-28 08:46

from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import shopapp.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('myauth', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Basket',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=200, verbose_name='Название категории товаров')),
                ('image', models.ImageField(blank=True, null=True, upload_to=shopapp.models.category_image_directory_path)),
            ],
            options={
                'verbose_name': 'Категория',
                'verbose_name_plural': 'Категории',
            },
        ),
        migrations.CreateModel(
            name='DeliveryPrices',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('delivery_cost', models.DecimalField(decimal_places=2, default=0, max_digits=8, verbose_name='Стоимость доставки')),
                ('delivery_express_cost', models.DecimalField(decimal_places=2, default=0, max_digits=8, verbose_name='Стоимость экспресс доставки')),
                ('delivery_free_minimum_cost', models.DecimalField(decimal_places=2, default=0, max_digits=8, verbose_name='Наименьшая сумма для бесплатной доставки')),
            ],
            options={
                'verbose_name': 'Стоимость доставки',
            },
        ),
        migrations.CreateModel(
            name='Order',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Дата создания заказа')),
                ('city', models.CharField(max_length=100, verbose_name='Город доставки')),
                ('delivery_address', models.CharField(max_length=200, verbose_name='Адрес доставки')),
                ('delivery_type', models.CharField(choices=[('delivery', 'Доставка'), ('express', 'Экспресс доставка')], default='Доставка', max_length=20)),
                ('payment_type', models.CharField(choices=[('online', 'Онлайн оплата'), ('online_any', 'Онлайн оплата со случайного счета')], default='Онлайн оплата', max_length=20)),
                ('total_cost', models.DecimalField(decimal_places=2, default=0, max_digits=8, verbose_name='Итоговая сумма заказа')),
                ('status', models.CharField(default='В обработке', max_length=255)),
                ('payment_error', models.CharField(blank=True, default='', max_length=255)),
                ('basket', models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, related_name='orders', to='shopapp.basket')),
                ('full_name', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='myauth.userprofile', verbose_name='Покупатель')),
            ],
            options={
                'verbose_name': 'Заказ',
                'verbose_name_plural': 'Заказы',
            },
        ),
        migrations.CreateModel(
            name='Product',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=200, verbose_name='Название продукта')),
                ('price', models.DecimalField(decimal_places=2, default=0, max_digits=8)),
                ('description', models.TextField(blank=True)),
                ('count', models.IntegerField(default=0)),
                ('date', models.DateTimeField(auto_now_add=True, verbose_name='Дата создания записи')),
                ('free_delivery', models.BooleanField(default=True)),
                ('count_of_orders', models.IntegerField(default=0)),
                ('rating', models.DecimalField(decimal_places=2, default=0.0, max_digits=3, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(5)])),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shopapp.category')),
            ],
            options={
                'verbose_name': 'Продукт',
                'verbose_name_plural': 'Продукты',
                'ordering': ['title', 'price'],
            },
        ),
        migrations.CreateModel(
            name='Specification',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(blank=True, max_length=50, null=True)),
                ('value', models.CharField(blank=True, max_length=100, null=True)),
            ],
            options={
                'verbose_name': 'Характеристика',
                'verbose_name_plural': 'Характеристики',
            },
        ),
        migrations.CreateModel(
            name='Tag',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200)),
            ],
            options={
                'verbose_name': 'Тег',
                'verbose_name_plural': 'Теги',
            },
        ),
        migrations.CreateModel(
            name='Subcategory',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=200, verbose_name='Название подкатегории товаров')),
                ('image', models.ImageField(blank=True, null=True, upload_to=shopapp.models.subcategory_image_directory_path)),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shopapp.category', verbose_name='Название подкатегории товаров')),
            ],
            options={
                'verbose_name': 'Подкатегория',
                'verbose_name_plural': 'Подкатегории',
            },
        ),
        migrations.CreateModel(
            name='Sale',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date_from', models.DateField()),
                ('date_to', models.DateField()),
                ('discount', models.DecimalField(decimal_places=2, max_digits=10)),
                ('product', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='sale_info', to='shopapp.product')),
            ],
        ),
        migrations.CreateModel(
            name='Review',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField(blank=True, null=True)),
                ('date', models.DateTimeField(auto_now_add=True, verbose_name='Дата и время создания отзыва')),
                ('rate', models.PositiveSmallIntegerField(validators=[django.core.validators.MaxValueValidator(5)], verbose_name='Оценка товара')),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='myauth.userprofile')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to='shopapp.product', verbose_name='Отзыв о товаре')),
            ],
            options={
                'verbose_name': 'Отзыв',
                'verbose_name_plural': 'Отзывы',
            },
        ),
        migrations.CreateModel(
            name='ProductImage',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('image', models.ImageField(upload_to=shopapp.models.product_image_directory_path)),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='shopapp.product')),
            ],
        ),
        migrations.AddField(
            model_name='product',
            name='specification',
            field=models.ManyToManyField(related_name='specification', to='shopapp.specification', verbose_name='Характеристика'),
        ),
        migrations.AddField(
            model_name='product',
            name='subcategory',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shopapp.subcategory'),
        ),
        migrations.AddField(
            model_name='product',
            name='tags',
            field=models.ManyToManyField(related_name='tags', to='shopapp.tag', verbose_name='Тег'),
        ),
        migrations.CreateModel(
            name='Payment',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('card_number', models.CharField(max_length=16)),
                ('validity_period', models.CharField(max_length=20)),
                ('success', models.BooleanField(default=False)),
                ('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pay_order', to='shopapp.order')),
            ],
        ),
        migrations.AddField(
            model_name='order',
            name='products',
            field=models.ManyToManyField(related_name='orders', to='shopapp.product'),
        ),
        migrations.CreateModel(
            name='BasketItem',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('quantity', models.PositiveSmallIntegerField(default=1)),
                ('basket', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='baskets', to='shopapp.basket')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='products', to='shopapp.product')),
            ],
        ),
    ]
